<div class="modal" ng-controller="DocumentModalBrowseController">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" ng-click="$hide()" aria-hidden="true">×
                </button>
                <h3>Add Link</h3>
            </div>

            <div class="modal-body modal-query">

                <div class="container-fluid">
                    <div class="row">
                        <div class="col-md-6">
                            <p><strong>Ctrl + Enter</strong> to execute the query</p>
                        </div>
                        <div class="col-md-6">
                            <form class="form-inline nomargin">
                                <button ng-click="query()" class="btn btn-xs pull-right">
                                    <i class="fa fa-cog"></i> Run
                                </button>
                            </form>
                        </div>
                    </div>
                    <div class="row">
                        <form ng:submit="query()" class="form-inline">
                            <div ui-codemirror="editorOptions" ng-model="queryText"></div>
                        </form>
                    </div>

                    <div class="row query-result">
                        <table class="table table-striped table-bordered table-hover table-condensed pointer"
                               ng-show="headers">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th ng-repeat="header in headers">{{header}}</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr ng-repeat="result in results">
                                <td><input type="checkbox" ng-click="select(result)"/></td>
                                <td ng-repeat="header in headers">{{result[header]}}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="alert alert-danger" ng-show="error">
                            {{error}}
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" ng-click="$hide()">Close</button>
                <button class="btn btn-primary" ng-disabled="added.length==0"
                        ng-click="modal.saved=true;$hide();createLink()">Add link
                </button>
            </div>
        </div>
    </div>
</div>
